package com.allqj.sfx.ddd.member.domain.enums;

import com.allqj.sfx.infrastructure.exceptions.BusinessException;

/**
 * @author sjw
 * @className BusinessExceptionEnum
 * @date 2022/7/20 15:07
 * @description: 会员管理——业务异常码
 */
public enum BusinessExceptionEnum {
    ARGS_ERROR(1101,"参数错误"),
    ACCOUNT_NOT_EXIST(1102,"账号不存在!"),
    ACCOUNT_PASSWORD_ERROR(1103,"密码错误!"),
    ACCOUNT_STATUS_ERROR(1104,"账号已被停用!"),
    ;

    //状态码
    private int statusCode;
    //描述信息
    private String message;

    BusinessExceptionEnum(int statusCode, String message) {
        this.statusCode = statusCode;
        this.message = message;
    }

    public int getStatusCode() {
        return statusCode;
    }

    public String getMessage() {
        return message;
    }

    public static void throwException(BusinessExceptionEnum status) {
        throw new BusinessException(status.getStatusCode(), status.getMessage());
    }

    public static void throwException(BusinessExceptionEnum status, String message) {
        throw new BusinessException(status.getStatusCode(), message);
    }

    public void throwException() {
        throw new BusinessException(getStatusCode(), getMessage());
    }
}
